package cn.edu.neusoft.demo.hospital2.Controller;

import cn.edu.neusoft.demo.hospital2.Service.DoctorWorkService;
import cn.edu.neusoft.demo.hospital2.pojo.DoctorWork;
import cn.edu.neusoft.demo.hospital2.common.Result;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@CrossOrigin(origins = "*")
@Tag(name = "DoctorWorkController相关的api")
@RequestMapping("/doctorWork")
public class DoctorWorkController {

    @Autowired
    private DoctorWorkService doctorWorkService;

    @Operation(summary = "医生查看自己的排班信息", description = "医生查看自己的排班信息")
    @GetMapping("/getMyWorkPlan")
    public Result getMyWorkPlan(@RequestParam String doctorId) {
        List<DoctorWork> list = doctorWorkService.getDoctorWorkByDoctorId(doctorId);
        return Result.ok(list);
    }

    @Operation(summary = "删除医生排班信息", description = "删除医生排班信息")
    @DeleteMapping
    public Result delete(@RequestParam String docId, @RequestParam String day) {
        int i = doctorWorkService.deleteByDocIdAndDay(docId, day);
        if (i > 0) {
            return Result.ok("删除成功");
        }
        return Result.fail("删除失败");
    }
}